Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for entitlement in DBP agent #2802

Merged
merged 17 commits into from
May 23, 2024
Merged

Check for entitlement in DBP agent #2802

merged 17 commits into from
May 23, 2024

Conversation

Bunn
Copy link
Collaborator

@Bunn Bunn commented May 21, 2024

Task/Issue URL: https://app.asana.com/0/1201011656765697/1206366654222841/f

Description:
Deactivates the DBP agent if entitlements are invalid

Steps to test this PR:
The main changes here are in DefaultDataBrokerProtectionAgentStopper and DataBrokerProtectionSubscriptionEventHandler which now checks for entitlement.

  1. Start from scratch removing the database and killing all agents you have running rm -rf ~/Library/Group\ Containers/HKE973VLUW.com.duckduckgo.macos.browser.dbp.debug and launchctl list | grep duck | awk '{print $3}' | xargs -n 1 launchctl remove
  2. Subscripe for privacy pro using the staging env (Set the staging env for subscription AND PIR in the debug menu)
  3. Check if you can correctly use the DBP feature
  4. Debug the agent and the browser and check in the console if we're sending the m_mac_dbp_macos_entitlement_valid pixels
  5. Change this to 2 minutes and check if we're correctly checking for entitlements every 2 minutes
  6. Change this to return false (AFAIK there's no other way to simulate this), and validate if we're correctly calling exit(0) in the agent and disableAndDelete in the browser
  7. Check that the agent dies if this validation fails, and no subsequent calls are made

Copy link
Contributor

github-actions bot commented May 21, 2024

Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS against 42264a4

Copy link
Contributor

@aataraxiaa aataraxiaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one @Bunn. Overall approach LGTM! Protocols will allow us to test etc, which is great. I know it’s a WIP, but left a few small questions/comments anyway.

extension DataBrokerProtectionEntitlementMonitoring {
func start(checkEntitlementFunction: @escaping () async throws -> Bool, callback: @escaping (DataBrokerProtectionEntitlementMonitorResult) -> Void) {
start(checkEntitlementFunction: checkEntitlementFunction,
intervalInMinutes: DataBrokerProtectionEntitlementMonitor.monitoringInterval,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: I don’t think it will cause issues, but something about the protocol extension referencing the concrete type static variable seems strange, or inverted. Maybe it’s a pattern, unsure, but wanted to highlight. Other options would be to just declare the constant in the function, or if we want every concrete type to have it’s own interval, define monitoringInterval as a protocol requirement.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Declaring the const in the function is the way to go IMO. The static const there is a leftover from some tests. Good call, thanks. I'll fix it

Copy link
Contributor

@aataraxiaa aataraxiaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a look at latest changes and they LGTM 👍🏼

Bunn added 5 commits May 22, 2024 11:27
testWhenAgentStart_andProfileDoesNotExist_thenActivityIsNotScheduled_andSheduledOpereationsNotRun is not required anymore since this flow is being tested on DataBrokerProtectionAgentStopperTests
@Bunn Bunn requested a review from aataraxiaa May 22, 2024 16:47
@github-actions github-actions bot added the bot: not in app board Added by automation for pull requests with tasks not added to macOS App Board Asana project label May 22, 2024
Copy link
Contributor

@aataraxiaa aataraxiaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good @Bunn . All test steps passed. Left some comments, the main ones relating to tests.

Base automatically changed from feature/pir-stabilization to main May 22, 2024 20:16
Copy link
Contributor

@aataraxiaa aataraxiaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes mostly look good 👍🏼, but the added test needs to be changed. See the comment.

agentFinishedLaunchingExpectation.fulfill()
})

// Then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not awaiting the completion of the expectation here, so it’s reaching the asserts immediately, before any of the completion handlers are called. Also, if we want to wait for each completion, we will need multiple expectations.

# Conflicts:
#	DuckDuckGo/Application/AppDelegate.swift
#	DuckDuckGo/DBP/DataBrokerProtectionSubscriptionEventHandler.swift
@Bunn Bunn changed the title WIP: checking for entitlement Check for entitlement in DBP agent May 23, 2024
@Bunn Bunn marked this pull request as ready for review May 23, 2024 09:11
@Bunn Bunn removed the bot: not in app board Added by automation for pull requests with tasks not added to macOS App Board Asana project label May 23, 2024
Copy link
Contributor

@aataraxiaa aataraxiaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest changes LGTM 🎉

@Bunn Bunn merged commit 2104521 into main May 23, 2024
16 of 19 checks passed
@Bunn Bunn deleted the bunn/dbp/entitlement branch May 23, 2024 10:26
samsymons added a commit that referenced this pull request May 23, 2024
# By Fernando Bunn (3) and others
# Via GitHub
* main:
  Autofill engagement KPIs for pixel reporting (#2806)
  autofill: don't prefix autofill email pixels with `m.mac.` (#2808)
  Bump BSK (#2807)
  Make profile selector optional (#2811)
  Add History to iOS (updated UI and rollout) (#2770)
  New autofill save & update password prompt pixels for alignment with iOS (#2801)
  Add mylife data broker (#2786)
  Increase test timeout (#2810)
  Subscription refactoring, BSK update (#2809)
  Check for entitlement in DBP agent (#2802)
  move permanent survey card to first position (#2804)

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
samsymons added a commit that referenced this pull request May 24, 2024
# By Elle Sullivan (8) and others
# Via Elle Sullivan (3) and GitHub (2)
* main: (26 commits)
  Autofill engagement KPIs for pixel reporting (#2806)
  autofill: don't prefix autofill email pixels with `m.mac.` (#2808)
  Bump BSK (#2807)
  Make profile selector optional (#2811)
  Add History to iOS (updated UI and rollout) (#2770)
  New autofill save & update password prompt pixels for alignment with iOS (#2801)
  Add mylife data broker (#2786)
  Increase test timeout (#2810)
  Subscription refactoring, BSK update (#2809)
  Check for entitlement in DBP agent (#2802)
  move permanent survey card to first position (#2804)
  Subscription refactoring (#2764)
  Bump version to 1.89.0 (191)
  Merge pir stabilization feature branch into main (#2789)
  Update age params for multiple brokers (#2800)
  Fix top level navigation blocks (#2792)
  Adding to the Dock automatically (#2722)
  Fix lint error
  Make activity only call completion once all work has actually finished
  Fix activity scheduler not calling completion
  ...

# Conflicts:
#	DuckDuckGo.xcodeproj/project.pbxproj
#	DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
samsymons added a commit that referenced this pull request May 30, 2024
* main: (33 commits)
  Remove autofill survey (#2819)
  Bump version to 1.90.0 (192)
  Set marketing version to 1.90.0
  Update embedded files
  Privacy Pro survey support (#2816)
  Update PeopleWhiz Broker Files to use hash id (#2814)
  Update BSK due to iOS changes. (#2776)
  Scroll address bar to caret when using arrows (#2799)
  Privacy Pro macOS quick follow ups (#2813)
  BSK bump for iOS RMF updates (#2798)
  Autofill engagement KPIs for pixel reporting (#2806)
  autofill: don't prefix autofill email pixels with `m.mac.` (#2808)
  Bump BSK (#2807)
  Make profile selector optional (#2811)
  Add History to iOS (updated UI and rollout) (#2770)
  New autofill save & update password prompt pixels for alignment with iOS (#2801)
  Add mylife data broker (#2786)
  Increase test timeout (#2810)
  Subscription refactoring, BSK update (#2809)
  Check for entitlement in DBP agent (#2802)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants